pointer: Replace old primitives with createPointers#697
pointer: Replace old primitives with createPointers#697
createPointers#697Conversation
|
| @@ -1,4 +1,4 @@ | |||
| import { createPointerListeners, pointerHover, createPointerList } from "../src/index.js"; | |||
| import { createPointerListeners, pointerHover, createPointerList } from "../src/index-ols.js"; | |||
There was a problem hiding this comment.
haven’t touched demo yet
well I did
but by mistake
it’s wip :)
| ); | ||
| if (onGotCapture) addEventListener("gotpointercapture", onGotCapture); | ||
| if (onLostCapture) addEventListener("lostpointercapture", onLostCapture); | ||
| function upsert_pointer(pointers: PointerEvent[], e: PointerEvent): PointerEvent[] { |
There was a problem hiding this comment.
update/insert
it’s such a cool shortcut I’m upsert I don’t see it more :)
| const up_event_touch = new PointerEvent("pointerup", { pointerId: 2, pointerType: "touch" }); | ||
| const cancel_event_touch = new PointerEvent("pointercancel", { pointerId: 2, pointerType: "touch" }); | ||
|
|
||
| const ref = document.createElement("div"); |
There was a problem hiding this comment.
Using the same ref for all tests seem a bit brittle.
It's probably a good time to remove that crap that was the pointer package and replace it with a simple, but actually useful primitive.
The old api was just an experimentation that ended up too complicated and not at at useful. The package is not used much either judging by the downloads.
The new
createPointersprimitive is simple, but it something I would use, it just gives you a list of pointer events of pointers that are currently on the screen. All the other magic like position_to_element, is_inside and is_down can be derived from this list, and I'll be adding examples how to do that to the readme later.